@import '@material/linear-progress/mixins.import';
@import '@material/theme/functions.import';
@import '../mdc-helpers/mdc-helpers';

@mixin _mat-mdc-progress-bar-color($color) {
  // TODO(crisbeto): the buffer color should come from somewhere in MDC, however at the time of
  // writing, their buffer color is hardcoded to #e6e6e6 which both doesn't account for theming
  // and doesn't match the Material design spec. For now we approximate the buffer background by
  // lightening the color of the primary bar.
  $buffer-color: lighten(mdc-theme-prop-value($color), 30%);
  @include mdc-linear-progress-bar-color($color, $query: $mat-theme-styles-query);
  @include mdc-linear-progress-buffer-color($buffer-color, $query: $mat-theme-styles-query);
}

@mixin mat-mdc-progress-bar-color($config-or-theme) {
  $config: mat-get-color-config($config-or-theme);
  @include mat-using-mdc-theme($config) {
    .mat-mdc-progress-bar {
      @include _mat-mdc-progress-bar-color(primary);

      &.mat-accent {
        @include _mat-mdc-progress-bar-color(secondary);
      }

      &.mat-warn {
        @include _mat-mdc-progress-bar-color(error);
      }
    }
  }
}

@mixin mat-mdc-progress-bar-typography($config-or-theme) {}

@mixin mat-mdc-progress-bar-density($config-or-theme) {}

@mixin mat-mdc-progress-bar-theme($theme-or-color-config) {
  $theme: mat-private-legacy-get-theme($theme-or-color-config);
  @include mat-private-check-duplicate-theme-styles($theme, 'mat-mdc-progress-bar') {
    $color: mat-get-color-config($theme);
    $density: mat-get-density-config($theme);
    $typography: mat-get-typography-config($theme);

    @if $color != null {
      @include mat-mdc-progress-bar-color($color);
    }
    @if $density != null {
      @include mat-mdc-progress-bar-density($density);
    }
    @if $typography != null {
      @include mat-mdc-progress-bar-typography($typography);
    }
  }
}
